/**
 * @author cRyann
 * @create 2017-08-21 13:03
 **/

import com.mj.mes.Application;
import com.mj.processController.DynamicProcess;
import org.activiti.bpmn.model.BpmnModel;
import org.activiti.engine.RepositoryService;
import org.dom4j.DocumentException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author cRyann
 * @create 2017-08-21 13:03
 **/
@SpringBootTest(classes = Application.class)
@RunWith(SpringJUnit4ClassRunner.class)
public class test_2 {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private RepositoryService repositoryService;
    @Autowired
    private DynamicProcess dynamicProcess;

    @Test
    public  void createXmlFile() throws DocumentException, IOException {
        String sql = "SELECT sequence_number,production_processes FROM technological_process ";
        List<Map<String, Object>> list = null;
        List<Map<String,String>> list1 = new ArrayList<>();
        String id = "testid";
        String name = "testname";
        try {
            list = jdbcTemplate.queryForList(sql);
        } catch (DataAccessException e) {
            e.printStackTrace();
        }

        for (Map<String,Object> map : list ){
            Map<String,String> result = new HashMap<>();
            result.put("id","userTask"+map.get("sequence_number").toString());
            result.put("name",map.get("production_processes").toString());
            list1.add(result);
        }
//        DynamicProcess dynamicProcess = new DynamicProcess();
//        BpmnModel model = dynamicProcess.createDynamicPocess("m822","m822",list1);
//                Deployment deployment = repositoryService.createDeployment()
//                .addBpmnModel("m822"+".bpmn", model)
//                .name("m822")
//                .deploy();
    }
}
